import React, { Component, lazy } from "react";
import { Router, Route, Redirect, Switch } from "react-router-dom";
// import Login from "./pages/Login";
// import Layout from "./pages/Layout";
import AuthRoutes from "components/AuthRoutes";
import NotFound from "pages/404";
import history from "./utils/history";
const Login = lazy(() => import("./pages/Login"));
const Layout = lazy(() => import("./pages/Layout"));
export default class App extends Component {
  render() {
    return (
      <Router history={history}>
        <React.Suspense fallback={<div>。。。loading加载中</div>}>
          <Switch>
            {/* 路由重定向 */}
            <Route path="/" render={() => <Redirect to="/home"></Redirect>} exact></Route>
            <Route path="/login" component={Login}></Route>
            <AuthRoutes path="/home" component={Layout}></AuthRoutes>
            <Route component={NotFound}></Route>
          </Switch>
        </React.Suspense>
      </Router>
    );
  }
}
